/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package ua.yandex.bank;

import java.util.concurrent.atomic.AtomicInteger;

/**
 *
 * @author vlad
 */
public class Account {
    
    private static AtomicInteger idGen = new AtomicInteger(0);
    
    private int id;
    private volatile long balance;
    
    public Account() {
        this(0);
    }
    
    public Account(long balance) {
        this.id = idGen.getAndIncrement();
        this.balance = balance;
    }
    
    public int getID() {
        return id;
    }
    
    public void withdraw(long amount) {
        balance -= amount;
    }
    
    public void deposit(long amount) {
        balance += amount;
    }
    
    public long getBalance() {
        return balance;
    }
}
